package com.peaksport.framework.common.controller;

import javax.ws.rs.core.MediaType;

import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.peaksport.framework.base.controller.BaseController;
import com.peaksport.framework.extend.schedule.PKScheduleService;
import com.peaksport.pkms.system.entity.ScheduleDefEntity;

/**
 * 后台事务定义
 * 
 *
 * @author jinbin_guo 2019年8月4日
 *
 */
@RestSchema(schemaId ="pkms-framework-schedule")
@RequestMapping(value="schedule", produces = MediaType.APPLICATION_JSON)
public class ScheduleController extends BaseController {

	@Autowired
	private PKScheduleService service;
	
	@PostMapping("add")
	public ScheduleDefEntity addScheduleDef(@RequestParam(required=false) String number,
			@RequestParam String name,
			@RequestParam String runnableClass,
			@RequestParam String cron,
			@RequestParam(required=false) String desc,
			@RequestParam String microService,
			@RequestParam(required=false,defaultValue="true") boolean isMutex){
		ScheduleDefEntity scheduleDefEntity = service.addNewScheduleDef(number, name, runnableClass, cron, desc, microService, isMutex);
		return scheduleDefEntity;
	}
	@PostMapping("remove")
	public void removeScheduleDef(@RequestParam String pk) {
		service.delete(pk);
	}
	public void enabledScheduleDef() {}
	public void disableScheduleDef() {}
	public void resetMutexScheduleDef() {}
	
	
	

}
